package com.wr.config;

import com.wr.constant.GlobalConstant;
import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.Queue;
import org.springframework.amqp.core.TopicExchange;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author weirong
 * @Title:
 * @Description:
 * @date 2018/6/1511:33
 */
@Configuration
public class RabbitConfig {

    @Bean
    public Queue queueMessage(){
        return new Queue(GlobalConstant.BLOG_VIEW_COUNT_QUEUE,true);
    }

    @Bean
    TopicExchange exchange() {
        return new TopicExchange(GlobalConstant.TOPIC_EXCHANGE);
    }

    @Bean
    Binding bindingExchangeMessage(Queue queueMessage, TopicExchange exchange) {
        return BindingBuilder.bind(queueMessage).to(exchange).with(GlobalConstant.BLOG_VIEW_COUNT_QUEUE);
    }


}
